﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using EpiNEXT.Services;

namespace EpiNEXT.Presentation.Enter.Pages
{
    /// <summary>
    /// Interaction logic for Forms.xaml
    /// </summary>
    public partial class Forms : UserControl
    {
        public event FormOpenedHandler FormOpened;
        public event EventHandler BackButtonClicked;

        public delegate void FormOpenedHandler(object sender, Applications.Events.FormOpenedEventArgs e);

        public Forms()
        {
            InitializeComponent();
        }

        private void FormsSummaryView_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.OriginalSource is Grid)
            {
                Grid grdProject = (e.OriginalSource as Grid);
                object dataContext = grdProject.DataContext;

                if (FormOpened != null && dataContext is FormInfo)
                {
                    Applications.Events.FormOpenedEventArgs args = new Applications.Events.FormOpenedEventArgs(dataContext as FormInfo);
                    FormOpened(this, args);
                }
            }
        }

        private void backButton_Click(object sender, RoutedEventArgs e)
        {
            if (BackButtonClicked != null)
            {
                BackButtonClicked(this, new EventArgs());
            }
        }
    }
}
